<template>

  <view class="my-list">
    <Paglist
      v-model="dataList"
      :is-init-api="true"
      :parame="parame"
      @register="register"
      :scroll-top-bottom="260"
      :is-show-loadmore="dataList.length >= 1"
    >
      <template v-for="v in dataList" :key="v.id">
        <view class="list-item">
          <SendItem
            :id="v.id"
            :status="v.applyStatus"
            :title="v.title"
            :application-time="v.createTime"
            :bo-type="v.boType"
          ></SendItem>
        </view>
      </template>
    </Paglist>
  </view>
</template>
<script setup lang="ts">
  import Paglist from '@/components/Paglist/index.vue';
  import { useConList } from '@/components/Paglist/useConList';
  import { sendApplyRecord } from '@/api/businessOpportunities';
  import type {
    IIntentionApplyRecordData,
    IIntentionApplyRecordResult,
  } from '@/api/businessOpportunities/type';
  import { ref, provide, type PropType, watch } from 'vue';
  import RadioTagGroup, { type TagItem } from '../../components/RadioTagGroup.vue';
  import { IntentionStatusEnum } from '@/enums/businessOpportunitiesEnum';
  import { IntentionStatusText } from '../../intentionManage';
  import SendItem from '../../intentionManage/components/SendItem.vue';

  const props = defineProps({
    parame: {
      type: Object as PropType<IIntentionApplyRecordData>,
      default: null,
    },
  });

  provide('api', async (obj: IIntentionApplyRecordData) => {
    const res = await sendApplyRecord(obj);
    return res;
  });

  const dataList = ref<IIntentionApplyRecordResult[]>([]);

  watch(
    () => props.parame,
    () => {
      refresh();
    },
    { deep: true },
  );

  const [register, { refresh }] = useConList();

  defineExpose({
    refresh,
  });
</script>
<style lang="scss" scoped>
  .my-list {
    background-color: #f2f3f5;
    .list-item {
      padding: 0 30rpx;
      margin-bottom: 30rpx;
      &:nth-child(1) {
        padding-top: 30rpx;
      }
    }
  }
</style>
